From 3b34d0137e672387909494967123983d45db1ffd Mon Sep 17 00:00:00 2001
From: Ludovic CHEVALIER
Date: Wed, 12 Mar 2014 10:05:19 +0100
Subject: [PATCH] [PLUGINS] ~formidable 1.3.6 --> 1.9.1
---
www/plugins/facteur/classes/facteur.php | 101 +-
www/plugins/facteur/emails/texte.html | 2 +-
www/plugins/facteur/facteur_fonctions.php | 98 ++
www/plugins/facteur/facteur_pipelines.php | 33 +
www/plugins/facteur/inc/envoyer_mail.php | 38 +-
www/plugins/facteur/lang/facteur.xml | 30 +-
www/plugins/facteur/lang/facteur_de.php | 34 +-
www/plugins/facteur/lang/facteur_en.php | 19 +-
www/plugins/facteur/lang/facteur_es.php | 23 +-
www/plugins/facteur/lang/facteur_fa.php | 79 ++
www/plugins/facteur/lang/facteur_fr.php | 51 +-
www/plugins/facteur/lang/facteur_fr_tu.php | 79 ++
www/plugins/facteur/lang/facteur_nl.php | 79 ++
www/plugins/facteur/lang/facteur_sk.php | 7 +-
www/plugins/facteur/lang/paquet-facteur.xml | 23 +-
.../facteur/lang/paquet-facteur_de.php | 16 +
.../facteur/lang/paquet-facteur_fr.php | 2 +-
.../facteur/lang/paquet-facteur_fr_tu.php | 16 +
.../facteur/lang/paquet-facteur_nl.php | 16 +
.../facteur/lang/paquet-facteur_ru.php | 16 +
.../facteur/lib/markdownify/LICENSE_LGPL.txt | 504 +++++++
.../facteur/lib/markdownify/markdownify.php | 1192 +++++++++++++++++
.../lib/markdownify/markdownify_extra.php | 489 +++++++
.../lib/markdownify/parsehtml/parsehtml.php | 618 +++++++++
www/plugins/facteur/paquet.xml | 3 +-
.../phpmailer-php5/class.phpmailer.php | 8 +-
www/plugins/facteur/svn.revision | 12 +-
.../action/editer_formulaire.php | 4 +-
.../action/exporter_analyse_reponses.php | 11 +-
.../action/exporter_formulaires_reponses.php | 2 +-
.../action/vider_formulaire.php | 37 +
.../formidable_1_0/base/formidable_tables.php | 6 +-
.../formidable_administrations.php | 6 +
.../formidable_autorisations.php | 61 +-
.../formidable_1_0/formidable_pipelines.php | 26 +-
.../configurer_formidable_analyse.html | 15 +
.../formulaires/formidable.html | 7 +-
.../formidable_1_0/formulaires/formidable.php | 19 +-
.../formulaires/importer_formulaire.html | 1 +
.../formulaire-reponses-supprimer-24.png | Bin 0 -> 1423 bytes
www/plugins/formidable_1_0/inc/formidable.php | 5 +-
.../formidable_1_0/lang/formidable.xml | 13 +-
.../formidable_1_0/lang/formidable_de.php | 43 -
.../formidable_1_0/lang/formidable_en.php | 8 +-
.../formidable_1_0/lang/formidable_es.php | 3 -
.../formidable_1_0/lang/formidable_fr.php | 94 +-
.../formidable_1_0/lang/formidable_it.php | 47 +-
.../formidable_1_0/lang/formidable_sk.php | 14 +-
.../formidable_1_0/lang/paquet-formidable.xml | 4 +
.../lang/paquet-formidable_fr.php | 18 +-
.../modeles/formulaire_analyse.html | 9 +-
www/plugins/formidable_1_0/paquet.xml | 16 +-
.../squelettes/contenu/formulaire_edit.html | 40 +-
.../prive/squelettes/contenu/formulaires.html | 9 +-
.../prive/squelettes/extra/formulaire.html | 4 +-
.../squelettes/extra/formulaire_edit.html | 2 +-
.../extra/formulaires_reponses.html | 16 +-
.../squelettes/hierarchie/formulaire.html | 4 +-
.../hierarchie/formulaire_edit.html | 6 +-
.../squelettes/navigation/formulaire.html | 2 +-
.../squelettes/navigation/formulaires.html | 2 -
.../saisies-analyses/selection.html | 2 +-
www/plugins/formidable_1_0/svn.revision | 12 +-
www/plugins/formidable_1_0/todo.txt | 1 -
www/plugins/formidable_1_0/traiter/email.php | 21 +-
www/plugins/formidable_1_0/traiter/email.yaml | 7 +
.../formidable_1_0/traiter/enregistrement.php | 4 +-
.../traiter/enregistrement.yaml | 13 +
.../formulaires/construire_formulaire.html | 108 +-
www/plugins/saisies/inc/saisies.php | 105 +-
www/plugins/saisies/inc/saisies_afficher.php | 12 +-
www/plugins/saisies/inc/saisies_lister.php | 27 +-
.../saisies/inclure/generer_saisies.html | 4 +-
www/plugins/saisies/javascript/saisies.js | 10 +-
www/plugins/saisies/lang/paquet-saisies.xml | 25 +-
.../saisies/lang/paquet-saisies_ar.php | 18 +
.../saisies/lang/paquet-saisies_fr.php | 2 +-
.../saisies/lang/paquet-saisies_fr_tu.php | 19 +
.../saisies/lang/paquet-saisies_nl.php | 17 +
www/plugins/saisies/lang/saisies.xml | 33 +-
www/plugins/saisies/lang/saisies_ca.php | 101 +-
www/plugins/saisies/lang/saisies_de.php | 10 +-
www/plugins/saisies/lang/saisies_en.php | 18 +-
www/plugins/saisies/lang/saisies_es.php | 79 +-
www/plugins/saisies/lang/saisies_fa.php | 53 +-
www/plugins/saisies/lang/saisies_fr.php | 91 +-
www/plugins/saisies/lang/saisies_fr_tu.php | 154 ++-
www/plugins/saisies/lang/saisies_it.php | 49 +-
www/plugins/saisies/lang/saisies_nl.php | 190 +++
www/plugins/saisies/lang/saisies_ru.php | 208 ++-
www/plugins/saisies/lang/saisies_sk.php | 25 +-
www/plugins/saisies/paquet.xml | 4 +-
www/plugins/saisies/plugin.xml | 8 +-
.../saisies/saisies-vues/checkbox.html | 7 +-
www/plugins/saisies/saisies-vues/mot.html | 3 +
www/plugins/saisies/saisies-vues/oui_non.html | 2 +-
.../saisies/saisies-vues/selection.html | 2 +-
www/plugins/saisies/saisies/_base.html | 2 +-
.../saisies/saisies/articles_originaux.html | 2 +-
www/plugins/saisies/saisies/auteurs.html | 5 +-
www/plugins/saisies/saisies/auteurs.yaml | 14 +
www/plugins/saisies/saisies/case.html | 5 +-
www/plugins/saisies/saisies/case.yaml | 14 +
www/plugins/saisies/saisies/checkbox.html | 21 +-
www/plugins/saisies/saisies/checkbox.yaml | 26 +
.../saisies/saisies/choisir_objet.html | 2 +-
www/plugins/saisies/saisies/date.yaml | 14 +
.../saisies/saisies/date_jour_mois_annee.html | 9 +-
.../saisies/saisies/destinataires.html | 22 +-
.../saisies/saisies/destinataires.yaml | 21 +
www/plugins/saisies/saisies/explication.yaml | 14 +
www/plugins/saisies/saisies/fieldset.yaml | 14 +
www/plugins/saisies/saisies/groupe_mots.html | 9 +-
www/plugins/saisies/saisies/input.html | 2 +-
www/plugins/saisies/saisies/input.yaml | 40 +-
www/plugins/saisies/saisies/mot.html | 23 +-
www/plugins/saisies/saisies/mot.yaml | 131 ++
www/plugins/saisies/saisies/oui_non.html | 8 +-
www/plugins/saisies/saisies/oui_non.yaml | 14 +
www/plugins/saisies/saisies/pays.html | 2 +-
www/plugins/saisies/saisies/police.html | 2 +-
.../position_construire_formulaire.html | 2 +-
www/plugins/saisies/saisies/radio.html | 4 +-
www/plugins/saisies/saisies/radio.yaml | 14 +
www/plugins/saisies/saisies/secteur.html | 2 +-
.../saisies/saisies/selecteur_article.yaml | 14 +
.../saisies/saisies/selecteur_document.html | 2 +-
.../saisies/saisies/selecteur_langue.html | 2 +-
.../saisies/saisies/selecteur_rubrique.yaml | 14 +
.../saisies/selecteur_rubrique_article.yaml | 14 +
.../saisies/saisies/selecteur_site.html | 2 +-
www/plugins/saisies/saisies/selection.html | 2 +-
www/plugins/saisies/saisies/selection.yaml | 16 +-
.../saisies/saisies/selection_multiple.html | 2 +-
.../saisies/saisies/selection_multiple.yaml | 14 +
.../saisies/saisies/selection_par_groupe.html | 2 +-
.../saisies/saisies/statuts_auteurs.html | 2 +-
www/plugins/saisies/saisies/textarea.html | 2 +-
www/plugins/saisies/saisies/textarea.yaml | 14 +
www/plugins/saisies/saisies/true_false.html | 8 +-
www/plugins/saisies/saisies_pipelines.php | 19 +-
www/plugins/saisies/svn.revision | 8 +-
142 files changed, 5104 insertions(+), 1057 deletions(-)
create mode 100644 www/plugins/facteur/facteur_pipelines.php
create mode 100644 www/plugins/facteur/lang/facteur_fa.php
create mode 100644 www/plugins/facteur/lang/facteur_fr_tu.php
create mode 100644 www/plugins/facteur/lang/facteur_nl.php
create mode 100755 www/plugins/facteur/lang/paquet-facteur_de.php
create mode 100644 www/plugins/facteur/lang/paquet-facteur_fr_tu.php
create mode 100644 www/plugins/facteur/lang/paquet-facteur_nl.php
create mode 100644 www/plugins/facteur/lang/paquet-facteur_ru.php
create mode 100644 www/plugins/facteur/lib/markdownify/LICENSE_LGPL.txt
create mode 100644 www/plugins/facteur/lib/markdownify/markdownify.php
create mode 100644 www/plugins/facteur/lib/markdownify/markdownify_extra.php
create mode 100644 www/plugins/facteur/lib/markdownify/parsehtml/parsehtml.php
create mode 100644 www/plugins/formidable_1_0/action/vider_formulaire.php
create mode 100644 www/plugins/formidable_1_0/images/formulaire-reponses-supprimer-24.png
create mode 100644 www/plugins/formidable_1_0/lang/paquet-formidable.xml
create mode 100644 www/plugins/saisies/lang/paquet-saisies_ar.php
create mode 100644 www/plugins/saisies/lang/paquet-saisies_fr_tu.php
create mode 100644 www/plugins/saisies/lang/paquet-saisies_nl.php
create mode 100644 www/plugins/saisies/lang/saisies_nl.php
create mode 100644 www/plugins/saisies/saisies-vues/mot.html
create mode 100644 www/plugins/saisies/saisies/mot.yaml
diff --git a/www/plugins/facteur/classes/facteur.php b/www/plugins/facteur/classes/facteur.php
index ca3edab2..daedf1e2 100755
--- a/www/plugins/facteur/classes/facteur.php
+++ b/www/plugins/facteur/classes/facteur.php
@@ -89,13 +89,15 @@ class Facteur extends PHPMailer {
$this->AddCustomHeader("Errors-To: ".$this->Sender);
}
- if (!empty($options['cc'])) {
- $this->AddCC( $options['cc'] );
- }
- if (!empty($options['bcc'])) {
- $this->AddBCC( $options['bcc'] );
+ if (!defined('_TEST_EMAIL_DEST')){
+ if (!empty($options['cc'])) {
+ $this->AddCC( $options['cc'] );
+ }
+ if (!empty($options['bcc'])) {
+ $this->AddBCC( $options['bcc'] );
+ }
}
-
+
if (isset($options['smtp']) AND $options['smtp'] == 'oui') {
$this->Mailer = 'smtp';
$this->Host = $options['smtp_host'];
@@ -141,94 +143,15 @@ class Facteur extends PHPMailer {
}
/*
- * Transforme du HTML en texte brut, mais proprement, c'est-Ã -dire en essayant
- * de garder les titrages, les listes, etc
+ * Transforme du HTML en texte brut, mais proprement
+ * utilise le filtre facteur_mail_html2text
+ * @uses facteur_mail_html2text()
*
* @param string $html Le HTML Ã transformer
* @return string Retourne un texte brut formaté correctement
*/
function html2text($html){
- // On remplace tous les sauts de lignes par un espace
- $html = str_replace("\n", ' ', $html);
-
- // Supprimer tous les liens internes
- $texte = preg_replace("/\]*>(.*?)<\/a>/ims", "\\2", $html);
-
- // Supprime feuille style
- $texte = preg_replace(";;i", "", $texte);
-
- // Remplace tous les liens
- $texte = preg_replace("/\]*href=['\"](.*?)['\"][^>]*>(.*?)<\/a>/ims", "\\2 (\\1)", $texte);
-
- // Les titres
- $texte = preg_replace(";]*>;i", "\n= ", $texte);
- $texte = str_replace("
", " =\n\n", $texte);
- $texte = preg_replace(";]*>;i", "\n== ", $texte);
- $texte = str_replace("
", " ==\n\n", $texte);
- $texte = preg_replace(";]*>;i", "\n=== ", $texte);
- $texte = str_replace("
", " ===\n\n", $texte);
-
- // Une fin de liste
- $texte = preg_replace(";(u|o)l>;i", "\n\n", $texte);
-
- // Une saut de ligne *après* le paragraphe
- $texte = preg_replace(";]*>;i", "\n", $texte);
- $texte = preg_replace(";
;i", "\n\n", $texte);
- // Les sauts de ligne interne
- $texte = preg_replace(";
]*>;i", "\n", $texte);
-
- //$texte = str_replace('
', "\n".'-', $texte);
- $texte = preg_replace (';]*>;i', "\n".'- ', $texte);
-
-
- // accentuation du gras
- // texte -> **texte**
- $texte = preg_replace (';]*>;i','**' ,$texte);
- $texte = str_replace ('','**' ,$texte);
-
- // accentuation du gras
- // texte -> **texte**
- $texte = preg_replace (';]*>;i','**' ,$texte);
- $texte = str_replace ('','**' ,$texte);
-
-
- // accentuation de l'italique
- // texte -> *texte*
- $texte = preg_replace (';]*>;i','/' ,$texte);
- $texte = str_replace ('','*' ,$texte);
-
- // accentuation de l'italique
- // texte -> *texte*
- $texte = preg_replace (';]*>;i','/' ,$texte);
- $texte = str_replace ('','*' ,$texte);
-
- $texte = str_replace('œ', 'oe', $texte);
- $texte = str_replace(" ", " ", $texte);
- $texte = filtrer_entites($texte);
-
- // On supprime toutes les balises restantes
- $texte = supprimer_tags($texte);
-
- $texte = str_replace("\x0B", "", $texte);
- $texte = str_replace("\t", "", $texte) ;
- $texte = preg_replace(";[ ]{3,};", "", $texte);
-
- // espace en debut de ligne
- $texte = preg_replace("/(\r\n|\n|\r)[ ]+/", "\n", $texte);
-
- //marche po
- // Bring down number of empty lines to 4 max
- $texte = preg_replace("/(\r\n|\n|\r){3,}/m", "\n\n", $texte);
-
- //saut de lignes en debut de texte
- $texte = preg_replace("/^(\r\n|\n|\r)*/", "\n\n", $texte);
- //saut de lignes en debut ou fin de texte
- $texte = preg_replace("/(\r\n|\n|\r)*$/", "\n\n", $texte);
-
- // Faire des lignes de 75 caracteres maximum
- //$texte = wordwrap($texte);
-
- return $texte;
+ return facteur_mail_html2text($html);
}
/**
diff --git a/www/plugins/facteur/emails/texte.html b/www/plugins/facteur/emails/texte.html
index cb7fccf4..e8ed065b 100644
--- a/www/plugins/facteur/emails/texte.html
+++ b/www/plugins/facteur/emails/texte.html
@@ -89,7 +89,7 @@
style="color:#A39F9A !important;font-family: Verdana, Geneva, sans-serif; !important;font-size:90% !important;font-weight:normal !important;font-style:normal !important;text-decoration:none !important;vertical-align:top !important;text-align:left !important;">
- — Envoyé par #NOM_SITE_SPIP
+ — #SET{site,#NOM_SITE_SPIP}<:facteur:email_envoye_par{site=#GET{site}}:>
diff --git a/www/plugins/facteur/facteur_fonctions.php b/www/plugins/facteur/facteur_fonctions.php
index 3abf19a9..9c09ca43 100755
--- a/www/plugins/facteur/facteur_fonctions.php
+++ b/www/plugins/facteur/facteur_fonctions.php
@@ -286,4 +286,102 @@ function facteur_nl2br_si_pas_autobr($texte){
return (_AUTOBR?$texte:nl2br($texte));
}
+/**
+ * Transformer un mail HTML en mail Texte proprement :
+ * - les tableaux de mise en page sont utilisés pour structurer le mail texte
+ * - le reste du HTML est markdownifie car c'est un format texte lisible et conventionnel
+ *
+ * @param string $html
+ * @return string
+ */
+function facteur_mail_html2text($html){
+ // nettoyer les balises de mise en page html
+ $html = preg_replace(",(td|th)>,Uims","
",$html);
+ $html = preg_replace(",(table)>,Uims","@@@hr@@@",$html);
+ $html = preg_replace(",?(html|body|table|td|th|tbody|thead|center|article|section|span)[^>]*>,Uims","\n\n",$html);
+
+ // commentaires html et conditionnels
+ $html = preg_replace(",,Uims","\n",$html);
+ $html = preg_replace(",,Uims","\n",$html);
+
+ $html = preg_replace(",<(/?)(div|tr|caption)([^>]*>),Uims","<\\1p>",$html);
+ $html = preg_replace(",(\s*)+,ims","
",$html);
+ $html = preg_replace(",
\s*
,ims","
",$html);
+ $html = preg_replace(",\s*
,ims","",$html);
+ $html = preg_replace(",(\s*(@@@hr@@@)?\s*)+,ims","\\2",$html);
+ $html = preg_replace(",(\s*
),ims","",$html);
+
+ // succession @@@hr@@@
et
@@@hr@@@
+ $html = preg_replace(",@@@hr@@@\s*(<[^>]*>\s*)?
]*>,ims","@@@hr@@@\n",$html);
+ $html = preg_replace(",
]*>\s*(<[^>]*>\s*)?@@@hr@@@,ims","\n@@@hr@@@",$html);
+
+ $html = preg_replace(",,Uims","\n\\1\n
",$html);
+
+ // vider le contenu de qqunes :
+ $html = preg_replace(",]*>.*,Uims","\n",$html);
+
+ // Liens :
+ // Nettoyage des liens des notes de bas de page
+ $html = preg_replace("@([0-9]+)@", "\\3", $html);
+ // Supprimer tous les liens internes
+ $html = preg_replace("/\]*>(.*?)<\/a>/ims","\\2", $html);
+ // Remplace tous les liens
+ preg_match_all("/\]*>(.*?)<\/a>/ims", $html,$matches,PREG_SET_ORDER);
+ $prelinks = $postlinks = array();
+ foreach ($matches as $k => $match){
+ $link = "@@@link$k@@@";
+ $url = str_replace("&","&",$match[1]);
+ if ($match[2]==$match[1] OR $match[2]==$url){
+ // si le texte est l'url :
+ $prelinks[$match[0]] = "$link";
+ }
+ else {
+ // texte + url
+ $prelinks[$match[0]] = $match[2] . " ($link)";
+ }
+ $postlinks[$link] = $url;
+ }
+ $html = str_replace(array_keys($prelinks), array_values($prelinks),$html);
+
+ // les images par leur alt ?
+ // au moins les puces
+ $html = preg_replace(',]*alt="-"[^>]*>,Uims','-',$html);
+ // les autres
+ $html = preg_replace(',]*alt=[\'"]([^\'"]*)[\'"][^>]*>,Uims',"\\1",$html);
+ // on vire celles sans alt
+ $html = preg_replace(",?(img)[^>]*>,Uims","\n",$html);
+
+ // espaces
+ $html = str_replace(" "," ",$html);
+ $html = preg_replace(",\s+,ims","
",$html);
+
+ #return $html;
+ include_spip("lib/markdownify/markdownify");
+ $parser = new Markdownify('inline',false,false);
+ $texte = $parser->parseString($html);
+
+ $texte = str_replace(array_keys($postlinks), array_values($postlinks),$texte);
+
+
+ // trim et sauts de ligne en trop ou pas assez
+ $texte = trim($texte);
+ $texte = str_replace("
\n","\n",$texte);
+ $texte = preg_replace(",(@@@hr@@@\s*)+\Z,ims","",$texte);
+ $texte = preg_replace(",(@@@hr@@@\s*\n)+,ims","\n\n\n".str_pad("-",75,"-")."\n\n\n",$texte);
+ $texte = preg_replace(",(\n#+\s),ims","\n\n\\1",$texte);
+ $texte = preg_replace(",(\n\s*)(\n\s*)+(\n)+,ims","\n\n\n",$texte);
+
+
+ //
et
restants
+ $texte = str_replace(array("","
"),array("",""),$texte);
+
+ // entites restantes ? (dans du code...)
+ include_spip('inc/charsets');
+ $texte = unicode2charset($texte);
+ $texte = str_replace(array(''', '"'),array("'",'"'), $texte);
+
+
+ // Faire des lignes de 75 caracteres maximum
+ return trim(wordwrap($texte));
+}
?>
diff --git a/www/plugins/facteur/facteur_pipelines.php b/www/plugins/facteur/facteur_pipelines.php
new file mode 100644
index 00000000..2bdbdce4
--- /dev/null
+++ b/www/plugins/facteur/facteur_pipelines.php
@@ -0,0 +1,33 @@
+ 0)){
+ $ajout = ''._T('facteur:message_identite_email').'
';
+ $flux['data'] = preg_replace(",(]*class=[\"']editer editer_email_webmaster.*>)(.*